package org.example.cake.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.cake.entity.Orderpayinfo;
import java.util.List;

@Mapper
public interface OrderpayinfoMapper {
    int deleteByPrimaryKey(Integer payid);

    int insert(Orderpayinfo record);

    int insertSelective(Orderpayinfo record);

    Orderpayinfo selectByPrimaryKey(Integer payid);

    int updateByPrimaryKeySelective(Orderpayinfo record);

    int updateByPrimaryKey(Orderpayinfo record);


    /**
     * 添加支付信息和订单信息以及减少优惠券
     * @Date 2025-08-04 谭丽那
     * @param orderpayinfo 订单信息 （缺少蛋糕id以及订单id）
     * @return
     */
    @Insert("insert into orderpayinfo(addressid,deliverypay,discountid,remark,countpay,adddate) values (#{orderpayinfo.addressid},#{orderpayinfo.deliverypay},#{orderpayinfo.discountid},#{orderpayinfo.remark},#{orderpayinfo.countpay},#{orderpayinfo.adddate} )")
    Integer saveOrderpayinfo(@Param("orderpayinfo") Orderpayinfo orderpayinfo);
    /**
     * 根据时间查询payid
     * @Date 2025-08-04 谭丽娜
     * @param date
     * @return
     */
    @Select("select payid from orderpayinfo where `adddate`=#{date} ")
    Integer getorderinfo(@Param("date") String date);

    /**
     * 分页查询支付信息表
     */
    List<Orderpayinfo> selectOrderpayinfo(@Param("ordernum") String ordernum,
                                          @Param("address") String address,
                                          @Param("cakeName") String cakeName);
    int updateRemark(@Param("payid")int payid,  @Param("remark") String remark);

}